﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SCMainAPP.DTO;
using FirebirdSql.Data.FirebirdClient;

namespace SCMainAPP.DAL
{
    class AlunoDAL: BasicDAL
    {
        public AlunoDAL()
        {
               
        }

        /// <summary>
        /// Insere um aluno no banco
        /// </summary>
        /// <param name="dto">Obj Dto com os dados do aluno</param>
        /// <param name="fbt">transaction sql</param>
        public static void InserirAluno(AlunoDTO dto, FbTransaction fbt)
        {
            StringBuilder insertSB = new StringBuilder();
            insertSB.Append("INSERT INTO ALUNO (al_id, al_nome, al_end) ");
            insertSB.Append("VALUES (");
            insertSB.Append("(SELECT COALESCE(MAX(AL_ID)+1,1) FROM ALUNO)");
            insertSB.Append(", '");
            insertSB.Append(dto.alNome);
            insertSB.Append("', '");
            insertSB.Append(dto.alEnd);
            insertSB.Append("')");
            BasicDAL.ExecutaSQL(insertSB.ToString(), fbt);                
        }

    }
}
